home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / cursor.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  4KB  |  174 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* cursor.c */
  21.  
  22. #include "externs.h"
  23.  
  24.  
  25.  
  26.  
  27. void AVL_UPDATE_CURSOR()
  28. {
  29.     struct rccoord old;
  30.     AVL_EDIT_WINDOW_PTR w;
  31.     if (avl_hscroll_on)
  32.         return;
  33.     w = &avl_windows[avl_window];
  34.     w -> scr_col = AVL_COL() - w -> offset;
  35.     _settextposition(w -> scr_row, w -> scr_col);
  36. }
  37.  
  38.  
  39. void AVL_CURSOR_HOME()
  40. {
  41.     avl_windows[avl_window].txt_col = 0;
  42.     if (avl_windows[avl_window].offset > 0)  {
  43.         avl_windows[avl_window].offset = 0;
  44.         avl_windows[avl_window].txt_col= 0;
  45.         AVL_SCROLL();
  46.         }
  47.     else
  48.         AVL_UPDATE_LINE();
  49. }
  50.  
  51.  
  52.  
  53. void AVL_CURSOR_END()
  54. {
  55.     AVL_EDIT_WINDOW_PTR w;
  56.     short n, i, oldoffset;
  57.     char *d;
  58.     w = &avl_windows[avl_window];
  59.     oldoffset = w -> offset;
  60.     w -> txt_col = strlen (w -> current_line -> line);
  61.     if (w -> txt_col < 0)
  62.         w -> txt_col = 0;
  63.     w -> offset = AVL_OFFSET();
  64.     if (w -> offset != oldoffset)
  65.         AVL_SCROLL();
  66.     else
  67.         AVL_UPDATE_LINE();
  68.     AVL_UPDATE_CURSOR();
  69. }
  70.  
  71. void AVL_CURSOR_PGUP()
  72. {
  73.     int i;
  74.     AVL_EDIT_WINDOW_PTR w;
  75.     w = &avl_windows[avl_window];
  76.     for (i = 1; i < (w -> r2 - w -> r1 + 2); ++i)
  77.         AVL_CURSOR_UP(1);
  78.     AVL_UPDATE_CURSOR();
  79. }
  80.  
  81. void AVL_CURSOR_PGDN()
  82. {
  83.     int i;
  84.     AVL_EDIT_WINDOW_PTR w;
  85.     w = &avl_windows[avl_window];
  86.     for (i = 1; i < (w -> r2 - w -> r1 + 2); ++i)
  87.         AVL_CURSOR_DOWN(1);
  88.     AVL_UPDATE_CURSOR();
  89. }
  90.  
  91. void AVL_CURSOR_LEFT(int no)
  92. {
  93.     AVL_EDIT_WINDOW_PTR w;
  94.     w = &avl_windows[avl_window];
  95.     if (no <= 0) no = 1;
  96.     while ( no-- )  {
  97.         if (w -> txt_col > 0)  {
  98.             w -> txt_col -= 1;
  99.             if (w -> scr_col == 1)  {
  100.                 w -> offset = AVL_OFFSET();
  101.                 AVL_SCROLL();
  102.                 }
  103.             AVL_UPDATE_CURSOR();
  104.             }
  105.         }
  106. }
  107.  
  108. void AVL_CURSOR_RIGHT(int no)
  109. {
  110.     AVL_EDIT_WINDOW_PTR w;
  111.     w = &avl_windows[avl_window];
  112.     if (no <= 0) no = 1;
  113.     while ( no-- )  {
  114.         if ((w -> txt_col) < strlen(w -> current_line -> line))  {
  115.             w -> txt_col += 1;
  116.             if (w -> scr_col >= w -> c2)  {
  117.                 w -> offset = AVL_OFFSET();
  118.                 AVL_SCROLL();
  119.                 }
  120.             AVL_UPDATE_CURSOR();
  121.             }
  122.         }
  123. }
  124.  
  125.  
  126.  
  127. void AVL_CURSOR_UP(int no)
  128. {
  129.     AVL_EDIT_WINDOW_PTR w;
  130.     short att, k;
  131.     att = _settextcursor(0x2000);
  132.     w = &avl_windows[avl_window];
  133.     if (no <= 0) no = 1;
  134.     while (no --)  {
  135.         if (w -> head != w -> current_line -> previous)  {
  136.             w -> current_line = w -> current_line -> previous;
  137.             if (w -> scr_row == 1) {
  138.                 _scrolltextwindow( -1 );
  139.                 AVL_UPDATE_LINE();
  140.                 }
  141.             else {
  142.                 w -> scr_row -= 1;
  143.                 }
  144.             }
  145.         }
  146.     att = _settextcursor(att);
  147.     AVL_UPDATE_CURSOR();
  148. }
  149.  
  150. void AVL_CURSOR_DOWN(int no)
  151. {
  152.     AVL_EDIT_WINDOW_PTR w;
  153.     short att, k;
  154.     att = _settextcursor(0x2000);
  155.     w = &avl_windows[avl_window];
  156.     if (no <= 0) no = 1;
  157.     while ( no-- )  {
  158.         if (w -> head != w -> current_line -> next)  {
  159.             w -> current_line = w -> current_line -> next;
  160.             if (w -> scr_row == (w -> r2 - w -> r1 + 1)) {
  161.                 _scrolltextwindow( 1 );
  162.                 AVL_UPDATE_LINE();
  163.                 }
  164.             else {
  165.                 w -> scr_row += 1;
  166.                 }
  167.             }
  168.         }
  169.     att = _settextcursor(att);
  170.     AVL_UPDATE_CURSOR();
  171. }
  172.  
  173.  
  174.